<template>
  <div class="category_container">
    <div v-for="(v,i) in toCategoryList"
         :key="i">
      <div v-if="i % 2 == 0">
        <category-item-l :toCategory="toCategoryList[i]"
                         v-on:getRouterPathFromItem="getRouterPathFromItem"></category-item-l>
      </div>
      <div v-else>
        <category-item-r :toCategory="toCategoryList[i]"
                         v-on:getRouterPathFromItem="getRouterPathFromItem"></category-item-r>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    toCategoryList: {}
  },
  data () {
    return {
      categoryList: {}
    }
  },
  methods: {
    // 获取从categoryItem传递的路由路径
    getRouterPathFromItem (path) {
      // 将路由路径传递给Home组件
      this.$emit('getRouterPathFromCategory', path);
    },
  }
}
</script>
<style lang="less" scoped>
.category_container {
  margin-top: 20px;
}
</style>